home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / graphics / sin.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-05-16  |  2.4 KB  |  88 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H0000FF00&
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   1770
  6.    ClientLeft      =   1320
  7.    ClientTop       =   1860
  8.    ClientWidth     =   4425
  9.    Height          =   2175
  10.    Left            =   1260
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   1770
  13.    ScaleWidth      =   4425
  14.    Top             =   1515
  15.    Width           =   4545
  16. Dim PI As Double
  17. Sub Form_Activate ()
  18.     Const GRANULARITY = .03
  19.     Const LINE_HEIGHT = .05
  20.     Const LINE_WIDTH = .25
  21.     Dim i As Double
  22.     Dim TwicePI As Double, PiOver2 As Double
  23.     Dim p1 As Double, p2 As Double
  24.     TwicePI = PI * 2#
  25.     PiOver2 = PI / 2#
  26.     'Establish a coordinate system and draw axes.
  27.     form1.Scale (-TwicePI - .1, 1.1)-(TwicePI + .1, -1.1)
  28.     Line (-TwicePI, 0)-(TwicePI, 0)
  29.     Line (0, 1)-(0, -1)
  30.     'Draw marks on the horizontal axis.
  31.     For i = -TwicePI To TwicePI Step PI / 4#
  32.         Line (i, LINE_HEIGHT)-(i, -LINE_HEIGHT)
  33.     Next i
  34.     currenty = -.1
  35.     currentx = -TwicePI
  36.     Print "-2pi"
  37.     currenty = .2
  38.     currentx = -1.6 * PI
  39.     Print "-1.5pi"
  40.     currenty = .2
  41.     currentx = -.6 * PI
  42.     Print "-.5pi"
  43.     currenty = -.1
  44.     currentx = -1.1 * PI
  45.     Print "-pi"
  46.     currenty = .2
  47.     currentx = .4 * PI
  48.     Print ".5pi"
  49.     currenty = -.1
  50.     currentx = .93 * PI
  51.     Print "pi"
  52.     currenty = -.1
  53.     currentx = 1.4 * PI
  54.     Print "1.5pi"
  55.     currenty = .2
  56.     currentx = TwicePI - .4
  57.     Print "2pi"
  58.     'Draw marks and labels on the vertical axis.
  59.     For i = 1# To -1# Step -.25
  60.         Line (-LINE_WIDTH, i)-(LINE_WIDTH, i)
  61.     Next i
  62.     For i = 1# To .25 Step -.25
  63.         currentx = -.9
  64.         currenty = i + .05
  65.         Print Str$(i)
  66.     Next i
  67.     For i = -.25 To -1# Step -.25
  68.         currentx = .3
  69.         currenty = i + .05
  70.         Print Str$(i)
  71.     Next i
  72.     form1.Caption = "A graph of the sin from -2 PI to 2 PI."
  73.     p1 = Sin(-TwicePI)
  74.     For i = -TwicePI + GRANULARITY To TwicePI Step GRANULARITY
  75.         p2 = Sin(i)
  76.         Line (i, p1)-(i, p2)
  77.         p1 = p2
  78.     Next i
  79. End Sub
  80. Sub Form_Load ()
  81.     PI = Atn(1#) * 4
  82.     drawwidth = 2
  83.     form1.Width = .9 * screen.Width
  84.     form1.Height = .6 * screen.Height
  85.     form1.Top = .2 * screen.Height
  86.     form1.Left = .05 * screen.Width
  87. End Sub
  88.